﻿using DAL.Engine.Domain;
using DAL.Engine.Interface;
using System;

namespace DAL.Engine.Specification
{
    public class IsAdultUserSpecification : ISpecification<User>
    {
        public bool IsSatisfiedBy(User entity)
        {
            var today = DateTime.UtcNow;
            int age = today.Year - entity.DayOfBirth.ToUniversalTime().Year;
            if (today < entity.DayOfBirth.AddYears(age)) age--;
            return age > 21;
        }
    }
}
